package com.ruoyi.business.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.bizsys.domain.LoanIou;
import com.ruoyi.bizsys.service.ILoanIouService;
import com.ruoyi.bizsys.vo.MonnifyReservedAccount;
import com.ruoyi.business.service.ICustVaService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wqg
 * @description
 * @date 2022/3/30
 */
@RestController
public class CreateTransferToUsController {
    @Autowired
    private ILoanIouService loanIouService;

    @Autowired
    ICustVaService custVaService;

    @RequestMapping("/forcollection/getCreateTransferToUs")
    @Log(title = "查询虚拟账号", businessType = BusinessType.INSERT)
    public JSONObject getCreateTransferToUs(String id) {
        LoanIou loanIou = loanIouService.getById(id);
        MonnifyReservedAccount monnifyReservedAccounts = custVaService.getVaReservedAccount(loanIou.getCustNo());
        monnifyReservedAccounts.setBank(monnifyReservedAccounts.getBankName());
        //monnifyRepaymentService.initRepaymentOrder(loanIou);
        return JSON.parseObject(JSONObject.toJSONString(monnifyReservedAccounts));
    }

    @RequestMapping("/forcollection/monnify/reservedAccounts")
    @Log(title = "查询虚拟账号", businessType = BusinessType.INSERT)
    public JSONObject getMonnifyReservedAccounts(String custNo) {
        MonnifyReservedAccount monnifyReservedAccounts = custVaService.getVaReservedAccount(custNo);
        return JSON.parseObject(JSONObject.toJSONString(monnifyReservedAccounts));
    }

}
